<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'static.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<link href="<%=basePath%>admin/static/css/basic.css" type="text/css"
	rel="stylesheet" />
<link href="<%=basePath%>admin/static/css/visualize.css"
	type="text/css" rel="stylesheet" />
<link href="<%=basePath%>admin/static/css/visualize-dark.css"
	type="text/css" rel="stylesheet" />

<script type="text/javascript" src="js/jquery.min.js"></script>

<script type="text/javascript"
	src="<%=basePath%>admin/static/js/visualize.jQuery.js"></script>
</head>

<body>
<div id = "saleCount" align="center">
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	var rowHtml = "";
	$.ajax({
		type : "POST",
		url : "servlet/SaleCountServlet",
		dataType:"json",
		success : function(result) {
			for(var key in result){
				rowHtml += "<tr><th scope=\"row\">"+key+"</th>";
				for(var i in result[key]){
					rowHtml += "<td>"+result[key][i]+"</td>";
				}
				rowHtml += "</tr>";
			}
			$("#saleCount").html("<table id=\"data\"><caption>销售记录</caption>"
			+"<thead><tr><td></td><th scope=\"col\">"+CurrentDateAddDay(180)+"-"+CurrentDateAddDay(150)+"</th><th scope=\"col\">"+CurrentDateAddDay(150)+"-"+CurrentDateAddDay(120)+"</th><th scope=\"col\">"+CurrentDateAddDay(120)+"-"+CurrentDateAddDay(90)+"</th>"
			+"<th scope=\"col\">"+CurrentDateAddDay(90)+"-"+CurrentDateAddDay(60)+"</th><th scope=\"col\">"+CurrentDateAddDay(60)+"-"+CurrentDateAddDay(30)+"</th><th scope=\"col\">"+CurrentDateAddDay(30)+"-现在</th></tr></thead>"
			+"<tbody>"+rowHtml+"</tbody></table>");
			$('table#data').visualize({type: 'line', width: '870px',height:'300px'});
		}
	});
});


function CurrentDateAddDay(n){
//http://www.cr173.com/html/18994_1.html
	var s="", d, t, t2;
	t = new Date().getTime();
    t2 = n * 1000 * 3600 * 24;
    t-= t2;
    d = new Date(t);
    s += (d.getUTCMonth()+1) + ".";
    s += d.getUTCDate();
    return s;
} 
</script>
</html>
